/**
 *WangGANG
 *2018/9/27
 */
package main

import (
	"encoding/xml"
	"os"
	"tool"
)

type Servers struct {
	XMLName xml.Name 	`xml:"servers"`
	Version string   	`xml:"version,attr"`
	Svs     []serverA 	`xml:"server"`
}

type serverA struct {
	ServerName string `xml:"serverName"`
	ServerIP   string `xml:"serverIP"`
}

func main() {
	cc := &Servers{Version:"1"}
	cc.Svs = append(cc.Svs,serverA{"Shanghai_VPN","127.0.0.1"})
	cc.Svs = append(cc.Svs,serverA{"beijing_VPN","127.0.0.2"})
	output,err := xml.MarshalIndent(cc," ","  ")
	tool.ErrTest(err)
	os.Stdout.Write([]byte(xml.Header)) //写xml头信息
	os.Stdout.Write([]byte(output))

}

